from django import forms
from django.core.exceptions import ValidationError

import pdb, json, requests
from user.models import VSession, FileStore, Company, WarZone
from software.models import SoftwareType, Software, SoftwareVersion, SoftwareData, SoftwareGroup, DuanInfo, PushOther
from storehouse.models import Storehouse
from order.models import SoftwareOrder


def token_check(value):
    # 验证token必须存在
    sessionList = VSession.objects.filter(token=value)
    if not sessionList.exists():
        errMsg = 'token Error'
        raise ValidationError(errMsg)
    else:
        session = sessionList[0]


# 文件检查
def fileList_check(value):
    # 验证token必须存在
    fileId = json.loads(value)
    for i in fileId:
        is_num_by_except(i)
        file = FileStore.objects.filter(pk=i)
        if not file.exists():
            errMsg = 'fileIdList Error'
            raise ValidationError(errMsg)
        else:
            session = file[0]


# 文件检查
def file_check(value):
    # 验证token必须存在
    is_num_by_except(value)
    file = FileStore.objects.filter(pk=value)
    if not file.exists():
        errMsg = 'fileId Error'
        raise ValidationError(errMsg)
    else:
        session = file[0]


def softwareType_check(value):
    # 验证token必须存在
    is_num_by_except(value)
    softwareType = SoftwareType.objects.filter(pk=value)
    if not softwareType.exists():
        errMsg = 'softwareType Error'
        raise ValidationError(errMsg)
    else:
        session = softwareType[0]


def company_check(value):
    # 验证token必须存在
    is_num_by_except(value)
    company = Company.objects.filter(pk=value)
    if not company.exists():
        errMsg = 'company Error'
        raise ValidationError(errMsg)
    else:
        session = company[0]


def warZone_check(value):
    # 验证token必须存在
    is_num_by_except(value)
    warZone = WarZone.objects.filter(pk=value)
    if not warZone.exists():
        errMsg = 'warZone Error'
        raise ValidationError(errMsg)
    else:
        session = warZone[0]


def software_check(value):
    # 验证token必须存在
    is_num_by_except(value)
    software = Software.objects.filter(pk=value)

    if not software.exists():
        errMsg = 'software Error'
        raise ValidationError(errMsg)
    else:
        session = software[0]


def storeHouse_check(value):
    # 验证token必须存在
    is_num_by_except(value)
    store = Storehouse.objects.filter(pk=value)
    if not store.exists():
        errMsg = 'store Error'
        raise ValidationError(errMsg)
    else:
        session = store[0]


def softwareVersion_check(value):
    # 验证token必须存在
    is_num_by_except(value)
    softwareVersion = SoftwareVersion.objects.filter(pk=value)

    if not softwareVersion.exists():
        errMsg = 'softwareVersion Error'
        raise ValidationError(errMsg)
    else:
        session = softwareVersion[0]


def dataId_check(value):
    # 验证软件id必须存在
    is_num_by_except(value)
    if value != -1:
        data = SoftwareData.objects.filter(pk=value)
        if not data.exists():
            errMsg = 'dataId Error'
            raise ValidationError(errMsg)


def storehouseId_check(value):
    # 验证仓库id必须存在
    is_num_by_except(value)
    if value != -1:
        storehouse = Storehouse.objects.filter(pk=value)
        if not storehouse.exists():
            errMsg = 'storehouseId Error'
            raise ValidationError(errMsg)


def groupId_check(value):
    # 验证仓库id必须存在
    is_num_by_except(value)
    if value != -1:
        softwareGroup = SoftwareGroup.objects.filter(pk=value)
        if not softwareGroup.exists():
            errMsg = 'softwareGroup Error'
            raise ValidationError(errMsg)


def duanId_check(value):
    # 验证仓库id必须存在
    is_num_by_except(value)
    if value != -1:
        duanList = DuanInfo.objects.filter(pk=value)
        if not duanList.exists():
            errMsg = 'duanId Error'
            raise ValidationError(errMsg)


def pushId_check(value):
    # 验证仓库id必须存在
    is_num_by_except(value)
    if value != -1:
        pushList = PushOther.objects.filter(pk=value)
        if not pushList.exists():
            errMsg = 'pushId Error'
            raise ValidationError(errMsg)


def maxItem_check(value):
    if value < 1:
        errMsg = 'maxItem Error'
        raise ValidationError(errMsg)


def page_check(value):
    if value < 1:
        errMsg = 'page Error'
        raise ValidationError(errMsg)


def order_check(value):
    # 验证token必须存在
    is_num_by_except(value)
    order = SoftwareOrder.objects.filter(pk=value)
    if not order.exists():
        errMsg = 'order Error'
        raise ValidationError(errMsg)
    else:
        order = order[0]


def is_num_by_except(num):
    try:
        int(num)
        return True
    except ValueError:
        errMsg = 'value not int'
        raise ValidationError(errMsg)


class UploadSoftForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    softwareName = forms.CharField(max_length=20, required=False)
    cost = forms.CharField(max_length=20)
    storehouse = forms.CharField(max_length=20, validators=[storeHouse_check], required=False)
    softwareDetails = forms.CharField(max_length=8000)
    currentVersionDesc = forms.CharField(max_length=8000, required=False)
    version = forms.CharField(max_length=20)
    warZone = forms.CharField(max_length=20, validators=[warZone_check], required=False)
    company = forms.CharField(max_length=20, validators=[company_check], required=False)
    softwareType = forms.CharField(max_length=20, validators=[softwareType_check], required=False)
    fileId = forms.CharField(max_length=20, validators=[fileList_check])
    softwareId = forms.CharField(max_length=20, validators=[software_check], required=False)
    logo = forms.CharField(max_length=20, validators=[file_check])
    cover = forms.CharField(max_length=20, validators=[file_check])
    verification = forms.CharField(max_length=20, validators=[file_check])
    material = forms.CharField(max_length=2000, required=False)
    questionAnswer = forms.CharField(max_length=2000, required=False)
    isSeg = forms.CharField(max_length=10)

    def clean_version(self):
        version = self.cleaned_data['version']
        if "as" in version:
            raise ValidationError("You have forgotten about Fred!")
        return version

    def clean_material(self):
        cleaned_data = super(UploadSoftForm, self).clean()
        # pdb.set_trace()
        try:
            materialList = json.loads(cleaned_data.get('material'))
            # materialList = json.loads(self.cleaned_data['material'])
            if isinstance(materialList, list):
                for materialItem in materialList:
                    if 'id' in materialItem:
                        materialId = materialItem['id']
                        file_check(materialId)
                    else:
                        raise ValidationError("id None in  material")
                    if 'dataName' not in materialItem:
                        raise ValidationError("dataName None in  material")
                    # if 'updateDetails' not in materialItem:
                    #     raise ValidationError("dataName None in  material")
            else:
                raise ValidationError("material not list 1")
        except:
            raise ValidationError("material not list")
        return materialList

    def clean_questionAnswer(self):
        cleaned_data = super(UploadSoftForm, self).clean()
        try:
            questionAnswerList = json.loads(cleaned_data.get('questionAnswer'))
            if isinstance(questionAnswerList, list):
                for questionAnswerItem in questionAnswerList:
                    if 'id' in questionAnswerItem:
                        qaId = questionAnswerItem['id']
                        file_check(qaId)
                    else:
                        raise ValidationError("id None in  qa")
                    if 'dataName' not in questionAnswerItem:
                        raise ValidationError("dataName None in  qa")
            else:
                raise ValidationError("questionAnswer not list")
        except:
            raise ValidationError("questionAnswer not list")
        return questionAnswerList
    # def clean(self):
    #     logo = json.loads(self.cleaned_data['logo'])
    #     cover = json.loads(self.cleaned_data['cover'])
    #     verification = json.loads(self.cleaned_data['verification'])
    #     softwareId = json.loads(self.cleaned_data['softwareId'])
    #     if softwareId == '':
    #         if logo == '' or cover == '' or verification == '':
    #             raise ValidationError("logo cover verification none")
    #     return self.cleaned_data


class UploadForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    file = forms.FileField(required=False)
    fileType = forms.CharField(max_length=20)

    def clean(self):
        cleaned_data = super(UploadForm, self).clean()
        fileType = cleaned_data.get('fileType')
        # fileType = self.cleaned_data['fileType']
        if fileType not in ['material', 'verification', 'file', 'logo', 'cover', 'QAFile']:
            errMsg = 'fileType Error'
            raise ValidationError(errMsg)
        return self.cleaned_data


class SoftDetailForm(forms.Form):
    token = forms.CharField(required=False, max_length=100, validators=[token_check])
    softwareVersionId = forms.CharField(required=False, max_length=20, validators=[softwareVersion_check])
    softwareVersionID = forms.CharField(max_length=20, required=False)
    userType = forms.CharField(max_length=20, required=False)


class SoftwareListForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    page = forms.IntegerField(validators=[page_check])
    maxItem = forms.IntegerField(validators=[maxItem_check])
    versionId = forms.CharField(required=False, validators=[softwareVersion_check])
    softwareGroup = forms.CharField(required=False)

    def clean(self):
        cleaned_data = super(SoftwareListForm, self).clean()
        softwareGroup = cleaned_data.get('softwareGroup')
        token = cleaned_data.get('token')
        sessionList = VSession.objects.filter(token=token)
        if not sessionList.exists():
            errMsg = 'token Error'
            raise ValidationError(errMsg)
        else:
            session = sessionList[0]
            if session.user != None:
                if session.user.userType == '1':
                    if softwareGroup != '' and (softwareGroup not in ['0', '1', '2', '3']):
                        errMsg = 'softwareGroup Error'
                        raise ValidationError(errMsg)
                elif session.user.userType == '2':
                    if softwareGroup != '' and (softwareGroup not in ['0', '1']):
                        errMsg = 'softwareGroup Error'
                        raise ValidationError(errMsg)
                elif session.user.userType == '3':
                    if softwareGroup != '':
                        errMsg = 'softwareGroup Error'
                        raise ValidationError(errMsg)
                else:
                    pass
            else:
                errMsg = 'user Error'
                raise ValidationError(errMsg)
        return self.cleaned_data


class SoftOperationForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    softwareVersionId = forms.CharField(max_length=20, validators=[softwareVersion_check])
    operation = forms.IntegerField()
    verify = forms.CharField(max_length=20, required=False)
    isApply = forms.CharField(max_length=20, required=False)
    deliveryType = forms.CharField(max_length=20, required=False)
    isView = forms.CharField(max_length=200, required=False)
    isDownload = forms.CharField(max_length=200, required=False)
    rejectReason = forms.CharField(max_length=1000, required=False)
    orderId = forms.CharField(max_length=20, validators=[order_check], required=False)
    softFileId = forms.CharField(max_length=20, required=False, validators=[file_check])

    def clean(self):
        # 验证token必须存在
        cleaned_data = super(SoftOperationForm, self).clean()
        token = cleaned_data.get('token')
        operation = cleaned_data.get('operation')
        sessionList = VSession.objects.filter(token=token)
        if operation in [0, 1, 2, 3, 4, 5]:
            if not sessionList.exists():
                errMsg = 'token Error'
                raise ValidationError(errMsg)
            else:
                session = sessionList[0]
                if session.user != None:
                    if session.user.userType == '1':
                        if operation == 0:
                            pass
                        elif operation == 1:
                            pass
                        else:
                            errMsg = 'operation Error'
                            raise ValidationError(errMsg)
                    elif session.user.userType == '2':
                        if operation == 0:
                            verify = cleaned_data.get('verify')
                            # verify = self.cleaned_data['verify']
                            if verify == '' or (verify not in ['0', '1']):
                                errMsg = 'verify Error'
                                raise ValidationError(errMsg)
                            # isView = self.cleaned_data['isView']
                            # isDownload = self.cleaned_data['isDownload']
                            isView = cleaned_data.get('isView')
                            isDownload = cleaned_data.get('isDownload')
                            if verify == '0' and isView == '':
                                errMsg = 'isView Error'
                                raise ValidationError(errMsg)
                            else:
                                for company in json.loads(isView):
                                    company_check(company)
                            if verify == '0' and isDownload == '':
                                errMsg = 'isDownload Error'
                                raise ValidationError(errMsg)
                            else:
                                for company in json.loads(isDownload):
                                    company_check(company)
                            isApply = cleaned_data.get('isApply')
                            if isApply == '' or (isApply not in ['0', '1']):
                                errMsg = 'isApply Error'
                                raise ValidationError(errMsg)
                            deliveryType = cleaned_data.get('deliveryType')
                            if deliveryType == '' or (deliveryType not in ['0', '1', '2', '3']):
                                errMsg = 'deliveryType Error'
                                raise ValidationError(errMsg)
                        elif operation == 1:
                            pass
                        elif operation == 2:
                            pass
                        elif operation == 3:
                            pass
                        elif operation == 4:
                            pass
                        elif operation == 5:
                            pass
                        else:
                            errMsg = 'operation Error'
                            raise ValidationError(errMsg)
                    elif session.user.userType == '3':
                        if operation == 0:
                            pass
                        else:
                            errMsg = 'operation Error'
                            raise ValidationError(errMsg)
                    else:
                        errMsg = 'userType Error'
                        raise ValidationError(errMsg)
                else:
                    errMsg = 'user Error'
                    raise ValidationError(errMsg)
        else:
            errMsg = 'operation Error'
            raise ValidationError(errMsg)
        return self.cleaned_data


class SoftSearchForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    page = forms.IntegerField(validators=[page_check])
    maxItem = forms.IntegerField(validators=[maxItem_check])
    softwareName = forms.CharField(max_length=50, required=False)
    uploadStartTime = forms.CharField(max_length=20, required=False)
    uploadEndTime = forms.CharField(max_length=20, required=False)
    storehouseId = forms.CharField(max_length=20, required=False, validators=[storeHouse_check])
    examineState = forms.CharField(max_length=20, required=False)
    softwareGroup = forms.CharField(max_length=20, required=False)
    softwareTypeId = forms.IntegerField(validators=[softwareType_check], required=False)

    def clean(self):
        cleaned_data = super(SoftSearchForm, self).clean()
        uploadStartTime = cleaned_data.get('uploadStartTime')
        uploadEndTime = cleaned_data.get('uploadEndTime')
        # uploadStartTime = self.cleaned_data['uploadStartTime']
        # uploadEndTime = self.cleaned_data['uploadEndTime']
        if uploadEndTime == '' and uploadStartTime != '':
            errMsg = 'One Time Empty'
            raise ValidationError(errMsg)
        elif uploadEndTime != '' and uploadStartTime == '':
            errMsg = 'One Time Empty'
            raise ValidationError(errMsg)
        else:
            pass
        examineState = cleaned_data.get('examineState')
        # examineState = self.cleaned_data['examineState']
        if examineState != '' and (examineState not in ['0', '1', '2']):
            errMsg = 'examineState Error'
            raise ValidationError(errMsg)
        # softwareGroup = self.cleaned_data['softwareGroup']
        softwareGroup = cleaned_data.get('softwareGroup')
        token = cleaned_data.get('token')
        # token = self.cleaned_data['token']
        sessionList = VSession.objects.filter(token=token)
        if not sessionList.exists():
            errMsg = 'token Error'
            raise ValidationError(errMsg)
        else:
            session = sessionList[0]
            if session.user != None:
                if session.user.userType == '1':
                    if softwareGroup != '' and (softwareGroup not in ['0', '1', '2']):
                        errMsg = 'softwareGroup Error'
                        raise ValidationError(errMsg)
                elif session.user.userType == '2':
                    if softwareGroup != '' and (softwareGroup not in ['0', '1']):
                        errMsg = 'softwareGroup Error'
                        raise ValidationError(errMsg)
                elif session.user.userType == '3':
                    if softwareGroup != '' and (softwareGroup not in ['0']):
                        errMsg = 'softwareGroup Error'
                        raise ValidationError(errMsg)
                else:
                    pass
            else:
                errMsg = 'user Error'
                raise ValidationError(errMsg)
        return self.cleaned_data


class DataOperationForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    dataId = forms.IntegerField(validators=[dataId_check])
    operation = forms.CharField(max_length=20)

    def clean(self):
        operation = self.cleaned_data['operation']
        if operation != '' and (operation not in ['0', '1', '2']):
            errMsg = 'operation Error'
            raise ValidationError(errMsg)
        return self.cleaned_data


class DataCheckForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    dataId = forms.IntegerField(validators=[dataId_check])
    verify = forms.CharField(max_length=20)
    dataResult = forms.CharField(max_length=20, required=False)

    def clean(self):
        verify = self.cleaned_data['verify']
        token = self.cleaned_data['token']
        sessionList = VSession.objects.filter(token=token)
        if not sessionList.exists():
            errMsg = 'token Error'
            raise ValidationError(errMsg)
        else:
            session = sessionList[0]
            if session.user != None:
                if session.user.userType == '1':
                    errMsg = 'user.userType Error'
                    raise ValidationError(errMsg)
                elif session.user.userType == '2':
                    if verify != '' and (verify not in ['0', '1']):
                        errMsg = 'verify Error'
                        raise ValidationError(errMsg)
                elif session.user.userType == '3':
                    errMsg = 'user.userType Error'
                    raise ValidationError(errMsg)
                else:
                    pass
            else:
                errMsg = 'user Error'
                raise ValidationError(errMsg)
        return self.cleaned_data


class GetDataListForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    maxItem = forms.IntegerField(validators=[maxItem_check])
    page = forms.IntegerField(validators=[page_check])
    softwareGroup = forms.CharField(max_length=20)

    def clean(self):
        softwareGroup = self.cleaned_data['softwareGroup']
        if softwareGroup != '' and (softwareGroup not in ['0', '1', '2', '3']):
            errMsg = 'softwareGroup Error'
            raise ValidationError(errMsg)
        return self.cleaned_data


class DataScreenForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    keyWord = forms.CharField(max_length=20, required=False)
    dataCheckState = forms.CharField(max_length=20, required=False)
    group = forms.CharField(max_length=20, required=False)
    storehouseId = forms.IntegerField(validators=[storehouseId_check], required=False)
    maxItem = forms.IntegerField(validators=[maxItem_check])
    page = forms.IntegerField(validators=[page_check])


class GetStorehouseListForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    maxItem = forms.IntegerField(validators=[maxItem_check])
    page = forms.IntegerField(validators=[page_check])


class GetTypeListForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    maxItem = forms.IntegerField(validators=[maxItem_check])
    page = forms.IntegerField(validators=[page_check])


class GroupListForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    page = forms.IntegerField(validators=[page_check])
    maxItem = forms.IntegerField(validators=[maxItem_check])
    softwareGroup = forms.CharField(max_length=20)

    def clean(self):
        cleaned_data = super(GroupListForm, self).clean()
        softwareGroup = cleaned_data.get('softwareGroup')
        if softwareGroup not in ['0', '1']:
            errMsg = 'softwareGroup Error'
            raise ValidationError(errMsg)
        return self.cleaned_data


class GroupSearchForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    page = forms.IntegerField(validators=[page_check])
    maxItem = forms.IntegerField(validators=[maxItem_check])
    softwareGroup = forms.CharField(max_length=20, required=False)
    category = forms.CharField(max_length=20, required=False)
    groupName = forms.CharField(max_length=200, required=False)

    def clean(self):
        cleaned_data = super(GroupSearchForm, self).clean()
        softwareGroup = cleaned_data.get('softwareGroup')
        category = cleaned_data.get('category')
        if softwareGroup not in ['0', '1']:
            errMsg = 'softwareGroup Error'
            raise ValidationError(errMsg)
        if category not in ['0', '1', '2', '3', '']:
            errMsg = 'category Error'
            raise ValidationError(errMsg)
        return self.cleaned_data


class GroupDetailForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    groupId = forms.IntegerField(validators=[groupId_check])


class GroupOperateForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    groupId = forms.IntegerField(validators=[groupId_check])
    operate = forms.CharField(max_length=20)

    def clean(self):
        operate = self.cleaned_data['operate']
        if operate not in ['0', '1', '2', '3']:
            errMsg = 'operate Error'
            raise ValidationError(errMsg)
        return self.cleaned_data


class GroupServiceOperateForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    groupName = forms.CharField(max_length=200)
    groupDetail = forms.CharField(max_length=1000)
    category = forms.CharField(max_length=20)
    planName = forms.CharField(max_length=100, required=False)
    planContent = forms.CharField(max_length=100, required=False)
    selectSoftware = forms.CharField(max_length=20000)

    def clean(self):
        # todo Only admin
        category = self.cleaned_data['category']
        if category in ['0', '1', '2', '3', '']:
            selectSoftware = self.cleaned_data['selectSoftware']
            try:
                selectSoftware1 = json.loads(selectSoftware)
                for software in selectSoftware1:
                    if 'softwareId' in software:
                        software_check(software['softwareId'])
                        if 'softwareVersion' in software:
                            for softwareVersion in software['softwareVersion']:
                                # pdb.set_trace()
                                if 'id' in softwareVersion:
                                    softwareVersion_check(softwareVersion['id'])
                                else:
                                    errMsg = 'Id None Error'
                                    raise ValidationError(errMsg)
                        else:
                            errMsg = 'softwareVersion None Error'
                            raise ValidationError(errMsg)
                    else:
                        errMsg = 'SoftwareId None Error'
                        raise ValidationError(errMsg)
            except Exception as e:
                errMsg = str(e) + ' selectSoftware Error'
                raise ValidationError(errMsg)
        else:
            errMsg = 'category Error'
            raise ValidationError(errMsg)
        return self.cleaned_data


class GroupDownLoadForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    groupId = forms.IntegerField(validators=[groupId_check])
    isUrl = forms.IntegerField()


class DataUpdateForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    fileId = forms.IntegerField(validators=[file_check], required=False)
    materialName = forms.CharField(max_length=200, required=False)
    dataId = forms.CharField(max_length=20, validators=[dataId_check])


class GetTypeForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    page = forms.IntegerField(validators=[page_check])
    maxItem = forms.IntegerField(validators=[maxItem_check])


class SoftwareTypeOptionForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check])
    softwareTypeId = forms.IntegerField(validators=[softwareType_check], required=False)
    softwareTypeState = forms.CharField(max_length=100, required=False)
    softwareType = forms.CharField(max_length=100, required=False)
    option = forms.CharField(max_length=100)

    def clean(self):
        cleaned_data = super(SoftwareTypeOptionForm, self).clean()
        option = cleaned_data.get('option')
        softwareTypeState = cleaned_data.get('softwareTypeState')
        if option not in ['0', '1', '2']:
            errMsg = 'option Error'
            raise ValidationError(errMsg)
        if softwareTypeState not in ['', '0', '1']:
            errMsg = 'softwareTypeState Error'
            raise ValidationError(errMsg)
        return self.cleaned_data

    def clean_softwareType(self):
        softwareType = self.cleaned_data['softwareType']
        softwareTypeName = SoftwareType.objects.filter(softwareType=softwareType)
        # pdb.set_trace()
        if len(softwareTypeName) == 1:
            errMsg = 'softwareType is exist'
            raise ValidationError(errMsg)
        return softwareType


class DetailGetForm(forms.Form):
    token = forms.CharField(required=False, max_length=100, validators=[token_check])
    softwareVersionId = forms.CharField(required=False, max_length=20, validators=[softwareVersion_check])


class QaGetForm(forms.Form):
    token = forms.CharField(required=False, max_length=100, validators=[token_check])


class EmptyPass(forms.Form):
    pass


class DelteForm(forms.Form):
    token = forms.CharField(required=False, max_length=100, validators=[token_check])
    id = forms.CharField(max_length=20, validators=[dataId_check])
    versionId = forms.CharField(max_length=20, validators=[softwareVersion_check])
    option = forms.CharField(max_length=200)


class GetHashForm(forms.Form):
    token = forms.CharField(required=False, max_length=100, validators=[token_check])


class ChunkForm(forms.Form):
    token = forms.CharField(required=False, max_length=100, validators=[token_check])
    file = forms.FileField(required=False)
    fileType = forms.CharField(required=False, max_length=2000)
    chunkNumber = forms.CharField(required=False, max_length=2000)
    currentChunkSize = forms.CharField(required=False, max_length=2000)
    totalSize = forms.CharField(required=False, max_length=2000)
    identifier = forms.CharField(required=False, max_length=2000)
    filename = forms.CharField(required=False, max_length=2000)
    totalChunks = forms.CharField(required=False, max_length=2000)


class GetDuanInfoForm(forms.Form):
    token = forms.CharField(required=False, max_length=100, validators=[token_check])
    softwareVersionId = forms.CharField(required=False, max_length=20, validators=[softwareVersion_check])


class GetDuanInfoServerForm(forms.Form):
    page = forms.IntegerField(validators=[page_check])
    maxItem = forms.IntegerField(validators=[maxItem_check])



class ContainerListForm(forms.Form):
    token = forms.CharField(required=False, max_length=100, validators=[token_check])
    page = forms.IntegerField(validators=[page_check])
    maxItem = forms.IntegerField(validators=[maxItem_check])


class PushDuanToOtherForm(forms.Form):
    token = forms.CharField(required=False, max_length=100, validators=[token_check])
    duanId = forms.IntegerField(validators=[duanId_check])


class GetPushListForm(forms.Form):
    token = forms.CharField(required=False, max_length=100, validators=[token_check])
    page = forms.IntegerField(validators=[page_check])
    maxItem = forms.IntegerField(validators=[maxItem_check])
    state = forms.CharField(required=False, max_length=20)


class GetPushStateForm(forms.Form):
    state = forms.CharField(max_length=20)
    id = forms.CharField(max_length=20, validators=[pushId_check])
    msg = forms.CharField(required=False, max_length=200)

class saveForm(forms.Form):
    token = forms.CharField(max_length=100, validators=[token_check], required=False)
    userName = forms.CharField(max_length=100, required=False)